<!DOCTYPE html>
<!-- 
	引入thymeleaf
	源码查看ThymeleafAutoConfiguration这个类，
	配置类是ThymeleafProperties。
 -->
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<!-- 
	2、链接url表达式：@{}
 -->
<link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
<script type="text/javascript" th:src="@{/layui/layui.js}"
	charset="utf-8"></script>
</head>
<body>
	<fieldset class="layui-elem-field layui-field-title"
		style="margin-top: 20px;">
		<legend>学生信息</legend>
	</fieldset>
	<div style="padding: 20px; background-color: #F2F2F2;">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card">
					<!-- 
						1、信息表达式：#{}
						可读取配置文件中的信息
					 -->
					<div class="layui-card-header" th:text="#{page.i18n}"></div>
					<div class="layui-card-body">
						<span>学号：</span> <span th:text="#{student.id}"></span>
					</div>
					<div class="layui-card-body">
						<span>姓名：</span> <span th:text="#{student.user-name}"></span>
					</div>
					<div class="layui-card-body">
						<span>年龄：</span> <span th:text="#{student.age}"></span>
					</div>
					<div class="layui-card-body">
						<span>兴趣爱好：</span> <span th:text="#{student.hobby}"></span>
					</div>
					<div class="layui-card-body">
						<span>出生日期：</span> <span th:text="#{student.birth}"></span>
					</div>
				</div>
			</div>
			<div class="layui-col-md12">
				<div class="layui-card">
					<div class="layui-card-header">李四的信息</div>
					<div class="layui-card-body">
						<!-- 
							3、变量表达式：${}
							可读取Model里面的对象
						 -->
						<span>学号：</span> <span th:text="${employee.id}"></span>
					</div>
					<div class="layui-card-body">
						<span>姓名：</span> <span th:text="${employee.name}"></span>
					</div>
					<div class="layui-card-body">
						<span>年龄：</span> <span th:text="${employee.age}"></span>
					</div>
					<div class="layui-card-body">
						<span>兴趣爱好：</span>
						<!-- 
							4、读取Model里面的集合：hobby:${employee.hobby}
							hobby是循环变量。
							${employee.hobby}是要循环的集合。
						 -->
						<span th:each="hobby:${employee.hobby}">
							<span th:text="${hobby}"></span>
						</span>
					</div>
					<!-- 
						时间格式转换工具：#dates.format()
					 -->
					<div class="layui-card-body">
						<span>出生日期：</span> <span
							th:text="${#dates.format({employee.birth},'yyyy-MM-dd HH:mm:ss')}"></span>
					</div>
					<!-- 
						数值转换工具类：#numbers.formatDecimal()
						第一个参数是你要转换的数值，第二参数是整数位数不足自动补全，第三参数是保留的小数（四舍五入）
					 -->
					<div class="layui-card-body">
						<span>工资：</span> <span
							th:text="${#numbers.formatDecimal(999999.028021,10,2)}"></span>
					</div>
				</div>
			</div>
			<div class="layui-col-md12">
				<div class="layui-card">
					<div class="layui-card-header">获取三大作用域中的值</div>
					<div class="layui-card-body">
						<!-- 
							8、作用域对象的读取
						 -->
						<span>request：</span> <span th:text="${#httpServletRequest.getAttribute('key')}"></span>
					</div>
					<div class="layui-card-body">
						<span>session：</span> <span th:text="${#httpSession.getAttribute('key')}"></span>
					</div>
					<div class="layui-card-body">
						<span>context：</span> <span th:text="${#servletContext.getAttribute('key')}"></span>
					</div>
					<div class="layui-card-body">
						<span>我的国家：</span> <span th:text="${#locale.country}+'-'+${#locale.getDisplayCountry}"></span>
					</div>
					<div class="layui-card-body">
						<span>我的母语：</span> <span th:text="${#locale.language}+'-'+${#locale.getDisplayLanguage}"></span>
					</div>
				</div>
			</div>
		</div>
	</div>
	<h2>
		<!-- 
			7、链接传值
		 -->
		<a th:href="@{/hello2(name=${employee.name},age='18')}">跳转到hello2页面&gt;&gt;</a>
	</h2>
	<script type="text/javascript">
		// 5、在js中取值
		var name = '[[${employee.name}]]';
		// 6、信息源的带参数访问
		var welcome = '[[#{welcome(${employee.name},${employee.age})}]]';
		alert(welcome+name);
	</script>
</body>
</html>